home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 July: Mac OS SDK / Dev.CD Jul 00 SDK2.toast / Development Kits / Cross Platform / QuickTime 4.1.2 Windows SDK / CIncludes / OSUtils.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-04-12  |  11.5 KB  |  452 lines  |  [TEXT/R*ch]

  1. /*
  2.      File:        OSUtils.h
  3.  
  4.      Contains:    OS Utilities Interfaces.
  5.  
  6.      Version:    Technology:    Mac OS 8
  7.                  Release:    QuickTime 4.1
  8.  
  9.      Copyright:    (c) 1985-1999 by Apple Computer, Inc., all rights reserved
  10.  
  11.      Bugs?:        For bug reports, consult the following page on
  12.                  the World Wide Web:
  13.  
  14.                      http://developer.apple.com/bugreporter/
  15.  
  16. */
  17. #ifndef __OSUTILS__
  18. #define __OSUTILS__
  19.  
  20. #ifndef __MACTYPES__
  21.     #include <MacTypes.h>
  22. #endif
  23.  
  24. #ifndef __MIXEDMODE__
  25.     #include <MixedMode.h>
  26. #endif
  27.  
  28. /*  HandToHand and other memory utilties were moved to MacMemory.h */
  29. #ifndef __MACMEMORY__
  30.     #include <MacMemory.h>
  31. #endif
  32.  
  33. /*  GetTrapAddress and other trap table utilties were moved to Patches.h */
  34. #ifndef __PATCHES__
  35.     #include <Patches.h>
  36. #endif
  37.  
  38. /*  Date and Time utilties were moved to DateTimeUtils.h */
  39. #ifndef __DATETIMEUTILS__
  40.     #include <DateTimeUtils.h>
  41. #endif
  42.  
  43. #if !TARGET_OS_MAC
  44. #ifndef __ENDIAN__
  45.     #include <Endian.h>
  46. #endif
  47.  
  48. #endif  /* !TARGET_OS_MAC */
  49.  
  50.  
  51.  
  52. #if PRAGMA_ONCE
  53. #pragma once
  54. #endif
  55.  
  56. #ifdef __cplusplus
  57. extern "C" {
  58. #endif
  59.  
  60. #if PRAGMA_IMPORT
  61. #pragma import on
  62. #endif
  63.  
  64. #if PRAGMA_STRUCT_ALIGN
  65.     #pragma options align=mac68k
  66. #elif PRAGMA_STRUCT_PACKPUSH
  67.     #pragma pack(push, 2)
  68. #elif PRAGMA_STRUCT_PACK
  69.     #pragma pack(2)
  70. #endif
  71.  
  72. enum {
  73.     useFree                        = 0,
  74.     useATalk                    = 1,
  75.     useAsync                    = 2,
  76.     useExtClk                    = 3,                            /*Externally clocked*/
  77.     useMIDI                        = 4
  78. };
  79.  
  80. enum {
  81.     false32b                    = 0,                            /*24 bit addressing error*/
  82.     true32b                        = 1                                /*32 bit addressing error*/
  83. };
  84.  
  85. enum {
  86.                                                                 /* result types for RelString Call */
  87.     sortsBefore                    = -1,                            /*first string < second string*/
  88.     sortsEqual                    = 0,                            /*first string = second string*/
  89.     sortsAfter                    = 1                                /*first string > second string*/
  90. };
  91.  
  92. enum {
  93.     dummyType                    = 0,
  94.     vType                        = 1,
  95.     ioQType                        = 2,
  96.     drvQType                    = 3,
  97.     evType                        = 4,
  98.     fsQType                        = 5,
  99.     sIQType                        = 6,
  100.     dtQType                        = 7,
  101.     nmType                        = 8
  102. };
  103.  
  104. typedef SignedByte                         QTypes;
  105.  
  106. struct SysParmType {
  107.     UInt8                             valid;
  108.     UInt8                             aTalkA;
  109.     UInt8                             aTalkB;
  110.     UInt8                             config;
  111.     short                             portA;
  112.     short                             portB;
  113.     long                             alarm;
  114.     short                             font;
  115.     short                             kbdPrint;
  116.     short                             volClik;
  117.     short                             misc;
  118. };
  119. typedef struct SysParmType                SysParmType;
  120.  
  121. typedef SysParmType *                    SysPPtr;
  122.  
  123. struct QElem {
  124.     struct QElem *                    qLink;
  125.     short                             qType;
  126.     short                             qData[1];
  127. };
  128. typedef struct QElem                    QElem;
  129. typedef QElem *                            QElemPtr;
  130. #if TARGET_OS_MAC
  131.  
  132. struct QHdr {
  133.     volatile short                     qFlags;
  134.     volatile QElemPtr                 qHead;
  135.     volatile QElemPtr                 qTail;
  136. };
  137. typedef struct QHdr                        QHdr;
  138. typedef QHdr *                            QHdrPtr;
  139. #else
  140. /*
  141.    QuickTime 3.0
  142.    this version of QHdr contains the Mutex necessary for
  143.    non-mac non-interrupt code
  144. */
  145.  
  146. struct QHdr {
  147.     volatile short                     qFlags;
  148.     short                             pad;
  149.     long                             MutexID;
  150.     volatile QElemPtr                 qHead;
  151.     volatile QElemPtr                 qTail;
  152. };
  153. typedef struct QHdr                        QHdr;
  154. typedef QHdr *                            QHdrPtr;
  155. #endif  /* TARGET_OS_MAC */
  156.  
  157. typedef CALLBACK_API( void , DeferredTaskProcPtr )(long dtParam);
  158. /*
  159.     WARNING: DeferredTaskProcPtr uses register based parameters under classic 68k
  160.              and cannot be written in a high-level language without 
  161.              the help of mixed mode or assembly glue.
  162. */
  163. typedef REGISTER_UPP_TYPE(DeferredTaskProcPtr)                     DeferredTaskUPP;
  164. #if OPAQUE_UPP_TYPES
  165.     EXTERN_API(DeferredTaskUPP)
  166.     NewDeferredTaskUPP               (DeferredTaskProcPtr        userRoutine);
  167.  
  168.     EXTERN_API(void)
  169.     DisposeDeferredTaskUPP           (DeferredTaskUPP            userUPP);
  170.  
  171.     EXTERN_API(void)
  172.     InvokeDeferredTaskUPP           (long                    dtParam,
  173.                                     DeferredTaskUPP            userUPP);
  174.  
  175. #else
  176.     enum { uppDeferredTaskProcInfo = 0x0000B802 };                     /* register no_return_value Func(4_bytes:A1) */
  177.     #define NewDeferredTaskUPP(userRoutine)                         (DeferredTaskUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppDeferredTaskProcInfo, GetCurrentArchitecture())
  178.     #define DisposeDeferredTaskUPP(userUPP)                         DisposeRoutineDescriptor(userUPP)
  179.     #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  180.     #pragma parameter InvokeDeferredTaskUPP(__A1, __A0)
  181.     void InvokeDeferredTaskUPP(long dtParam, DeferredTaskUPP userUPP) = 0x4E90;
  182.     #else
  183.         #define InvokeDeferredTaskUPP(dtParam, userUPP)                 CALL_ONE_PARAMETER_UPP((userUPP), uppDeferredTaskProcInfo, (dtParam))
  184.     #endif
  185. #endif
  186. /* support for pre-Carbon UPP routines: NewXXXProc and CallXXXProc */
  187. #define NewDeferredTaskProc(userRoutine)                         NewDeferredTaskUPP(userRoutine)
  188. #define CallDeferredTaskProc(userRoutine, dtParam)                InvokeDeferredTaskUPP(dtParam, userRoutine)
  189.  
  190. struct DeferredTask {
  191.     volatile QElemPtr                 qLink;
  192.     short                             qType;
  193.     volatile short                     dtFlags;
  194.     DeferredTaskUPP                 dtAddr;
  195.     long                             dtParam;
  196.     long                             dtReserved;
  197. };
  198. typedef struct DeferredTask                DeferredTask;
  199. typedef DeferredTask *                    DeferredTaskPtr;
  200. #if TARGET_OS_MAC
  201.  
  202. struct MachineLocation {
  203.     Fract                             latitude;
  204.     Fract                             longitude;
  205.     union {
  206.         SInt8                             dlsDelta;                /* signed byte; daylight savings delta */
  207.         long                             gmtDelta;                /* use low 24-bits only */
  208.     }                                 u;
  209. };
  210. typedef struct MachineLocation            MachineLocation;
  211. #else
  212. /*
  213.     QuickTime 3.0:
  214.     Alignment of MachineLocation is weird. The union above used for delta
  215.     tends not to work on non-Mac compilers.
  216. */
  217.  
  218. struct MachineLocation {
  219.     Fract                             latitude;
  220.     Fract                             longitude;
  221.     BigEndianLong                     delta;                        /* high byte is daylight savings delta, low 24-bits is GMT delta */
  222. };
  223. typedef struct MachineLocation            MachineLocation;
  224. #endif  /* TARGET_OS_MAC */
  225.  
  226. EXTERN_API( Boolean )
  227. IsMetric                        (void)                                                        THREEWORDINLINE(0x3F3C, 0x0004, 0xA9ED);
  228.  
  229. EXTERN_API( SysPPtr )
  230. GetSysPPtr                        (void)                                                        THREEWORDINLINE(0x2EBC, 0x0000, 0x01F8);
  231.  
  232.  
  233. /*
  234.     NOTE: SysBeep() has been moved to Sound.h.  
  235.           We could not automatically #include Sound.h in this file
  236.           because Sound.h indirectly #include's OSUtils.h which
  237.           would make a circular include.
  238. */
  239.                                                                                             #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  240.                                                                                             #pragma parameter __D0 DTInstall(__A0)
  241.                                                                                             #endif
  242. EXTERN_API( OSErr )
  243. DTInstall                        (DeferredTaskPtr         dtTaskPtr)                            ONEWORDINLINE(0xA082);
  244.  
  245.  
  246.  
  247. #if TARGET_CPU_PPC || !TARGET_OS_MAC
  248. #define GetMMUMode() ((SInt8)true32b)
  249. #define SwapMMUMode(x) (*(SInt8*)(x) = true32b)
  250. #else
  251. EXTERN_API( SInt8 )
  252. GetMMUMode                        (void)                                                        TWOWORDINLINE(0x1EB8, 0x0CB2);
  253.  
  254.                                                                                             #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  255.                                                                                             #pragma parameter SwapMMUMode(__A0)
  256.                                                                                             #endif
  257. EXTERN_API( void )
  258. SwapMMUMode                        (SInt8 *                mode)                                THREEWORDINLINE(0x1010, 0xA05D, 0x1080);
  259.  
  260. #endif
  261.                                                                                             #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  262.                                                                                             #pragma parameter Delay(__A0, __A1)
  263.                                                                                             #endif
  264. EXTERN_API( void )
  265. Delay                            (unsigned long             numTicks,
  266.                                  unsigned long *        finalTicks)                            TWOWORDINLINE(0xA03B, 0x2280);
  267.  
  268. EXTERN_API( OSErr )
  269. WriteParam                        (void);
  270.  
  271.                                                                                             #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  272.                                                                                             #pragma parameter Enqueue(__A0, __A1)
  273.                                                                                             #endif
  274. EXTERN_API( void )
  275. Enqueue                            (QElemPtr                 qElement,
  276.                                  QHdrPtr                 qHeader)                            ONEWORDINLINE(0xA96F);
  277.  
  278.                                                                                             #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  279.                                                                                             #pragma parameter __D0 Dequeue(__A0, __A1)
  280.                                                                                             #endif
  281. EXTERN_API( OSErr )
  282. Dequeue                            (QElemPtr                 qElement,
  283.                                  QHdrPtr                 qHeader)                            ONEWORDINLINE(0xA96E);
  284.  
  285.  
  286.                                                                                             #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  287.                                                                                             #pragma parameter __D0 SetCurrentA5
  288.                                                                                             #endif
  289. EXTERN_API( long )
  290. SetCurrentA5                    (void)                                                        THREEWORDINLINE(0x200D, 0x2A78, 0x0904);
  291.  
  292.                                                                                             #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  293.                                                                                             #pragma parameter __D0 SetA5(__D0)
  294.                                                                                             #endif
  295. EXTERN_API( long )
  296. SetA5                            (long                     newA5)                                ONEWORDINLINE(0xC18D);
  297.  
  298.                                                                                             #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  299.                                                                                             #pragma parameter __D0 InitUtil
  300.                                                                                             #endif
  301. EXTERN_API( OSErr )
  302. InitUtil                        (void)                                                        ONEWORDINLINE(0xA03F);
  303.  
  304.  
  305. #if TARGET_CPU_PPC
  306. EXTERN_API( void )
  307. MakeDataExecutable                (void *                    baseAddress,
  308.                                  unsigned long             length);
  309.  
  310. #endif  /* TARGET_CPU_PPC */
  311.  
  312.  
  313. #if TARGET_CPU_68K
  314. EXTERN_API( Boolean )
  315. SwapInstructionCache            (Boolean                 cacheEnable);
  316.  
  317. EXTERN_API( Boolean )
  318. SwapDataCache                    (Boolean                 cacheEnable);
  319.  
  320. EXTERN_API( void )
  321. FlushInstructionCache            (void)                                                        TWOWORDINLINE(0x7001, 0xA098);
  322.  
  323. EXTERN_API( void )
  324. FlushDataCache                    (void)                                                        TWOWORDINLINE(0x7003, 0xA098);
  325.  
  326. EXTERN_API( void )
  327. FlushCodeCache                    (void)                                                        ONEWORDINLINE(0xA0BD);
  328.  
  329. #endif  /* TARGET_CPU_68K */
  330.  
  331.                                                                                             #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  332.                                                                                             #pragma parameter __D0 FlushCodeCacheRange(__A0, __A1)
  333.                                                                                             #endif
  334. EXTERN_API( OSErr )
  335. FlushCodeCacheRange                (void *                    address,
  336.                                  unsigned long             count)                                TWOWORDINLINE(0x7009, 0xA098);
  337.  
  338.                                                                                             #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  339.                                                                                             #pragma parameter ReadLocation(__A0)
  340.                                                                                             #endif
  341. EXTERN_API( void )
  342. ReadLocation                    (MachineLocation *        loc)                                FOURWORDINLINE(0x203C, 0x000C, 0x00E4, 0xA051);
  343.  
  344.  
  345.                                                                                             #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  346.                                                                                             #pragma parameter WriteLocation(__A0)
  347.                                                                                             #endif
  348. EXTERN_API( void )
  349. WriteLocation                    (const MachineLocation * loc)                                FOURWORDINLINE(0x203C, 0x000C, 0x00E4, 0xA052);
  350.  
  351.  
  352.  
  353. #if OLDROUTINENAMES
  354. #define IUMetric() IsMetric()
  355. #endif  /* OLDROUTINENAMES */
  356.  
  357. /*
  358.     NOTE: SysEnvirons is obsolete.  You should be using Gestalt.
  359. */
  360. /* Environs Equates */
  361. enum {
  362.     curSysEnvVers                = 2                                /*Updated to equal latest SysEnvirons version*/
  363. };
  364.  
  365.  
  366. struct SysEnvRec {
  367.     short                             environsVersion;
  368.     short                             machineType;
  369.     short                             systemVersion;
  370.     short                             processor;
  371.     Boolean                         hasFPU;
  372.     Boolean                         hasColorQD;
  373.     short                             keyBoardType;
  374.     short                             atDrvrVersNum;
  375.     short                             sysVRefNum;
  376. };
  377. typedef struct SysEnvRec                SysEnvRec;
  378. enum {
  379.                                                                 /* Machine Types */
  380.     envMac                        = -1,
  381.     envXL                        = -2,
  382.     envMachUnknown                = 0,
  383.     env512KE                    = 1,
  384.     envMacPlus                    = 2,
  385.     envSE                        = 3,
  386.     envMacII                    = 4,
  387.     envMacIIx                    = 5,
  388.     envMacIIcx                    = 6,
  389.     envSE30                        = 7,
  390.     envPortable                    = 8,
  391.     envMacIIci                    = 9,
  392.     envMacIIfx                    = 11
  393. };
  394.  
  395. enum {
  396.                                                                 /* CPU types */
  397.     envCPUUnknown                = 0,
  398.     env68000                    = 1,
  399.     env68010                    = 2,
  400.     env68020                    = 3,
  401.     env68030                    = 4,
  402.     env68040                    = 5
  403. };
  404.  
  405. enum {
  406.                                                                 /* Keyboard types */
  407.     envUnknownKbd                = 0,
  408.     envMacKbd                    = 1,
  409.     envMacAndPad                = 2,
  410.     envMacPlusKbd                = 3,
  411.     envAExtendKbd                = 4,
  412.     envStandADBKbd                = 5,
  413.     envPrtblADBKbd                = 6,
  414.     envPrtblISOKbd                = 7,
  415.     envStdISOADBKbd                = 8,
  416.     envExtISOADBKbd                = 9
  417. };
  418.  
  419.                                                                                             #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  420.                                                                                             #pragma parameter __D0 SysEnvirons(__D0, __A0)
  421.                                                                                             #endif
  422. EXTERN_API( OSErr )
  423. SysEnvirons                        (short                     versionRequested,
  424.                                  SysEnvRec *            theWorld)                            ONEWORDINLINE(0xA090);
  425.  
  426.  
  427.  
  428.  
  429.  
  430.  
  431.  
  432. #if PRAGMA_STRUCT_ALIGN
  433.     #pragma options align=reset
  434. #elif PRAGMA_STRUCT_PACKPUSH
  435.     #pragma pack(pop)
  436. #elif PRAGMA_STRUCT_PACK
  437.     #pragma pack()
  438. #endif
  439.  
  440. #ifdef PRAGMA_IMPORT_OFF
  441. #pragma import off
  442. #elif PRAGMA_IMPORT
  443. #pragma import reset
  444. #endif
  445.  
  446. #ifdef __cplusplus
  447. }
  448. #endif
  449.  
  450. #endif /* __OSUTILS__ */
  451.  
  452.